<?php
/**
 * Created by PhpStorm.
 * User: idcu
 * Date: 2016/3/16
 * Time: 9:28
 */
namespace Service\Controller;
use Think\Controller;

class OaRunController extends Controller
{
    protected $modelName = CONTROLLER_NAME;

    //通过 RUN_ID 查找
    public function getRun(){
        $req = I('param.');
        if($req['RUN_ID'] == 'all'){
            $data = D($this->modelName)->relation(true)->select();
            $count = D($this->modelName)->count();
            $res['stat'] = $data ? 1 : 0;
            $res['msg'] = $data ? '找到'.$count.'条数据' : '没有找到数据';
            $res['data'] = $data;
        }elseif($req['RUN_ID']){
            $where['RUN_ID'] = $req['RUN_ID'];
            $data = D($this->modelName)->where($where)->relation(true)->find();
            $res['stat'] = $data ? 1 : 0;
            $res['msg'] = $data ? '找到1条数据' : '没有找到数据';
            $res['data'] = $data;
        }else{
            $res['stat'] = 0;
            $res['msg'] = '参数提交不正确';
        }
        $this->ajaxReturn($res);
    }
}